home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Browsers, Managers & Extensions
/
Mozilla Geode 1.5
/
geode-latest.xpi
/
content
/
geoprefs.xul
< prev
next >
Wrap
Extensible Markup Language
|
2008-10-02
|
6KB
|
177 lines
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="geoprefs" title="Geolocation Saved Preferences"
onload="init();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
<!--
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is labs.mozilla.com code.
*
* The Initial Developer of the Original Code is Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Justin Dolske <dolske@mozilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK *****
-->
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
var sitedata;
var listdata;
var deleteButton;
var cps = Cc["@mozilla.org/content-pref/service;1"].
getService(Ci.nsIContentPrefService);
function init() {
list = document.getElementById("list");
listdata = document.getElementById("listdata");
deleteButton = document.getElementById("deleteButton");
deleteButton.disabled = true;
sitedata = getSiteData();
for (var i = 0; i < sitedata.length; i++) {
addToList(sitedata[i].hostname, sitedata[i].fuzzLevel);
}
}
function getSiteData() {
var results = [];
// nsIContentPrefService doesn't have an API to list all saved settings,
// so we'll have to query its DB directly.
const query = "SELECT groups.name, prefs.value " +
"FROM prefs " +
"LEFT JOIN groups ON groups.id = prefs.groupID " +
"WHERE prefs.settingID = ( " +
" SELECT id " +
" FROM settings " +
" WHERE name = 'labs.geode.fuzzLevel' " +
")";
var stmt = cps.DBConnection.createStatement(query);
var wrappedStmt = Cc["@mozilla.org/storage/statement-wrapper;1"].
createInstance(Ci.mozIStorageStatementWrapper);
wrappedStmt.initialize(stmt);
while (wrappedStmt.step()) {
var result = { hostname : wrappedStmt.row.name,
fuzzLevel : wrappedStmt.row.value };
results.push(result);
}
return results;
}
function addToList(hostname, fuzzLevel) {
var treeItem = document.createElement("treeitem");
var treeRow = document.createElement("treerow");
var col1 = document.createElement("treecell");
var col2 = document.createElement("treecell");
var col3 = document.createElement("treecell");
col1.setAttribute("label", hostname);
col2.setAttribute("label", fuzzLevel >= 0 ? "Allowed" : "Denied");
if (fuzzLevel == -1)
col3.setAttribute("label", "");
else if (fuzzLevel == 0)
col3.setAttribute("label", "Exact Location");
else if (fuzzLevel == 200)
col3.setAttribute("label", "Neighborhood");
else if (fuzzLevel == 10000)
col3.setAttribute("label", "City");
else
col3.setAttribute("label", fuzzLevel + " meters");
treeRow.appendChild(col1);
treeRow.appendChild(col2);
treeRow.appendChild(col3);
treeItem.appendChild(treeRow);
// Insert into the list
listdata.appendChild(treeItem);
}
function onSelect() {
var isSelected = (list.view.selection.getRangeCount() > 0);
deleteButton.disabled = !isSelected;
}
function deleteSelection() {
var index = list.currentIndex;
var item = sitedata[index];
// Remove it from the real storage
// Ugh, we need a real URI to do this, but it's not saved in the DB. Just
// prepend "http://" to fudge it.
var ioService = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var uri = ioService.newURI("http://" + item.hostname, null, null);
cps.removePref(uri, "labs.geode.fuzzLevel");
// Remove it from our data array
sitedata.splice(index, 1);
// Remove it from the UI
listdata.removeChild(listdata.childNodes[index]);
list.view.selection.clearSelection();
}
]]>
</script>
<label value="These sites are automatically allowed (or prohibited) from accessing your position:"/>
<tree id="list"
seltype="single" rows="5"
onselect="onSelect();">
<treecols>
<treecol label="Site" flex="5"/>
<splitter class="tree-splitter"/>
<treecol label="Permission" flex="1"/>
<splitter class="tree-splitter"/>
<treecol label="Fuzzing" flex="1"/>
</treecols>
<treechildren id="listdata">
</treechildren>
</tree>
<hbox>
<spacer flex="1"/>
<button id="deleteButton" label="Delete" oncommand="deleteSelection();"/>
</hbox>
</window>